﻿using System.IO;

namespace OpenLS.Spreadsheet.Formats.Biff.Records
{
    internal class HLinkTooltipRecord : BiffRecord
    {
        private FrtRefHeaderNoGrbit frtRefHeaderNoGrbit;
        private byte[] wzTooltip;

        protected override void ReadContent(BiffReaderContext context, int length)
        {
            this.frtRefHeaderNoGrbit = new FrtRefHeaderNoGrbit();
            this.frtRefHeaderNoGrbit.Read(context.Reader);
            wzTooltip = context.ReadBytes(length - 10);
        }

        internal override BiffRecordType RecordType
        {
            get { return BiffRecordType.HLinkTooltip; }
        }

        internal override void WriteContent(BiffWriterWorkbookContext context)
        {
            this.frtRefHeaderNoGrbit.Write(context.Writer);
            context.Write(this.wzTooltip);
        }
    }

    internal class FrtRefHeaderNoGrbit
    {
        private ushort rt;
        private Ref8 ref8;

        public void Read(BinaryReader reader)
        {
            this.rt = reader.ReadUInt16();
            this.ref8 = new Ref8();
            ref8.Read(reader);
        }

        public void Write(BinaryWriter writer)
        {
            writer.Write(this.rt);
            ref8.Write(writer);
        }
    }
}